<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>登录</title>
    <link rel="stylesheet" th:href="@{/asserts/css/pintuer.css}"/>
    <link rel="stylesheet" th:href="@{/asserts/css/admin.css}"/>
    <script th:src="@{/asserts/js/jquery.js}"></script>
    <script th:src="@{/asserts/js/pintuer.js}"></script>
    <script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>

</head>
<body>
<div class="bg"></div>
<div class="container">
    <div class="line bouncein">
        <div class="xs6 xm4 xs3-move xm4-move">
            <div style="height:150px;"></div>
            <div class="media media-y margin-big-bottom">
            </div>
            <!--<form>-->
                <div class="panel loginbox">
                    <div class="text-center margin-big padding-big-top"><h1>高博应诺客户关系管理系统</h1></div>
                    <div class="panel-body" style="padding:30px; padding-bottom:10px; padding-top:10px;">
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="text" class="input input-big" name="username" autocomplete="off"
                                       id="username" placeholder="登录账号" required data-validate="required:请填写账号"/>
                                <span class="icon icon-user margin-small"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="field field-icon-right">
                                <input type="password" class="input input-big" name="password" id="password"
                                       placeholder="登录密码" required data-validate="required:请填写密码"/>
                                <span class="icon icon-key margin-small"></span>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="label">
                                <label><span id="info"
                                             style="font-size:16px; font-weight:bolder; color:red;"></span></label>
                            </div>
                        </div>
                    </div>
                    <div style="padding:30px;">
                        <button id="btn" class="button button-block bg-main text-big input-big">登录</button>
                    </div>
                </div>
            <!--</form>-->
        </div>
    </div>
</div>
<script>

    $(function () {
        $("#username").focus();
    })
    function login () {
        $.ajax({
            url: "[[${#httpServletRequest.getContextPath()}]]/member/login",
            type: "post",
            data: {
                username: $("#username").val(),
                password: $("#password").val()
            },
            success: function (result) {
                console.log(result);
                if (result == 0) {
                    $("#info").html("用户名或密码错误");
                }
                if (result == -1) {
                    $("#info").html("服务器错误!请联系管理员！");
                }
                if (result == 1) {
                    $("#info").html("登录成功!正在跳转。。。");
                    location.href = "[[${#httpServletRequest.getContextPath()}]]/starter";

                }
            },
            error: function (xrh, error, status) {
                $("#info").html("Ajax....服务器错误!请联系管理员！");
            }
        })
    }
    $('#password').bind('keyup',function (event) {
        if (event.keyCode == "13") {
            if ($("#username").val() == "" || $("#password").val() == ""){
                layer.msg('请填写账号或密码！', {icon: 0, time: 1000});
                return false;
            }
            //回车执行查询
            $("#btn").click(login());
            $("#password").val('hello_man_no_password');
        }
    });
    $("#btn").click(function () {
        console.log($("#username").val());
        console.log($("#password").val());
        if ($("#username").val() == "" || $("#password").val() == ""){
            layer.msg('请填写账号或密码！', {icon: 0, time: 1000});
            return false;
        }
        login();
        $("#password").val('hello_man_no_password');
    })
</script>
<script type="text/javascript">
    if(top.location != self.location){
        top.location = self.location;
    }
</script>
</body>
</html>